<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Inicio de Sesión</title>
<link rel="stylesheet" href="css/estilos.css" />
<style>
.errorblock {
	color: #ff0000;
	background-color: #ffEEEE;
	border: 3px solid #ff0000;
	padding: 8px;
	margin: 16px;
}
</style>
<script type="text/javascript">
	function validations() {

		if ("" == document.forms.loginForm.userCode.value
				|| "" == document.forms.loginForm.password.value) {
			alert("El campo usuario y password son requeridos.");
			return false;
		}

		return true;
	}
</script>
</head>
<body id="loginBody" onload='document.forms.loginForm.userCode.focus();'>

                                 
    <center>
		<c:if test="${not empty errorParam}" >
			<div class="mensajeError" >			
				 <strong>[${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}]</strong>  
				 <br/>
			</div>
		</c:if>
    </center>
	<section id="loginSection">
		<h1>Inicio de Sesión</h1>
		<c:url var="loginUrl" value="/j_spring_security_check" />
		<!--<c:url value="j_spring_security_check"  var="login"/>-->
		<form name="loginForm" 
			method="POST" action="${loginUrl}" onsubmit="return validations();">
			<input id="userCode" name="j_username"
				placeholder="Usuario" />
			<input  id="password" name="j_password"
				placeholder="Password" type="password" />
			<input type="submit" value="Iniciar" id="loginButton" />
		</form>
	</section>
</body>
</html>
